// ----------------------------------------------------------------------------
// serialize_float_scalar_type.h
// ----------------------------------------------------------------------------
/*
 Description:
 .
 */
#pragma once
#include <fw/base/serialize/serialize_scalar_type.h>
#include <fw/base/core/macros.h>

namespace fw
{
	class ByteWriter;
	
	template<typename T> class SerializeFloatScalarType : public SerializeScalarType
	{
	public:
		virtual void WriteScalarValue(char* data, const SerializeScalarValue& value) const
		{
			*reinterpret_cast<T*>(data) = static_cast<T>(value.AsFloat());
		}
		
		virtual SerializeScalarValue ReadScalarValue(const char* data) const
		{
			return SerializeScalarValue::Float(*reinterpret_cast<const T*>(data));
		}
		
		virtual size_t GetSize() const
		{
			return sizeof(T);
		}
		
		virtual size_t GetAlignment() const
		{
			return FW_ALIGNOF(T);
		}
		
		virtual bool IsBuiltIn() const
		{
			return true;
		}
		
		virtual void Write(ByteWriter& writer) const
		{ // All float scalar types are built-in.
		}
		
	}; // class SerializeFloatScalarType

} // namespace fw
